require "TSLib"

w,h = getScreenSize();
w,h=w-50,h-50
MyJsonString = [[
{
	"style": "default",
	"width": ]]..w..[[,
    "height": ]]..h..[[,
	"config": "save_mlzhhh.dat",
	"views": [
		{
			"type": "Label",
			"text": "夜神雷电模拟器手机版分辨率选择720*1280",
			"size": 20,
			"align": "center",
			"color": "0,0,255"
		},
		{
			"type": "Label",
			"text": "选择模式，打哪里就在那个图里把人摆好方可运行",
			"size": 18,
			"align": "left",
			"color": "0,0,255"
		},
		{
		"type": "CheckBoxGroup",
		"list": "账号1,账号2,账号3,账号4,账号5",
		"select": "0",
		"width": "160"
        }		
	]
}
]]
ret,xzms =  showUI(MyJsonString)


--xzms  选择模式
--sc    等待多久
--yxm   验证码

if ret == 0 then--如果选择【取消】，脚本退出
	lua_exit()
	mSleep(0)
	mSleep(0)
end

PAGE = {}
PAGE["返回游戏"] = {}
PAGE["返回游戏"]["返回游戏"] = {Unit = 0,Pixelpoint = {1004,  37, 0xffffff}}
PAGE["返回游戏"]["登陆"] = {Unit = 0,Pixelpoint = {49,   37, 0x2a84d8}}

PAGE["iosgod"] = {}  
PAGE["iosgod"]["thankyou"] = {Unit = 0,Pixelpoint = { 565,  554, 0xffffff }}
PAGE["iosgod"]["visrit"] = {Unit = 0,Pixelpoint = { 563,  465, 0xffffff}}
PAGE["iosgod"]["图标1"] = {Unit = 0,Pixelpoint = { 408,   375, 0x2866c0 }}
PAGE["iosgod"]["图标2"] = {Unit = 0,Pixelpoint = { 734,   384, 0x2866c0 }}


PAGE["使用"] = {}  
PAGE["使用"]["取消"] = {Unit = 0,Pixelpoint = { 455,   409, 0x3090fb }}
PAGE["使用"]["继续"] = {Unit = 0,Pixelpoint = { 684,   420, 0x77b2f7 }}

PAGE["小米"] = {}    
PAGE["小米"]["打勾"] = {Unit = 0,Pixelpoint = { 545,  430, 0x00fd00 }}
PAGE["小米"]["图标"] = {Unit = 0,Pixelpoint = { 590,  416, 0x00ff00 }}


PAGE["点击画面"] = {}
PAGE["点击画面"]["魔灵"] = {Unit = 0,Pixelpoint = {519,  301, 0x412a12 }}
PAGE["点击画面"]["召唤"] = {Unit = 0,Pixelpoint = {653,  353, 0xffffd6}}

PAGE["登陆界面"] = {}
PAGE["登陆界面"]["账号输入"] = {Unit = 0,Pixelpoint = {785,  255, 0xffffff }}
PAGE["登陆界面"]["登陆"] = {Unit = 0,Pixelpoint = {877,  311, 0x2b84d8 }}
PAGE["登陆界面"]["密码输入"] = {Unit = 0,Pixelpoint = {782,  359, 0xffffff}}

PAGE["输入法"] = {}
PAGE["输入法"]["删除"] = {Unit = 0,Pixelpoint = {1061,   523, 0x60646a }}
PAGE["输入法"]["完成"] = {Unit = 0,Pixelpoint = {1055,   220, 0x007aff }}

PAGE["密码输入法"] = {}	
PAGE["密码输入法"]["删除"] = {Unit = 0,Pixelpoint = {1043,   515, 0x000000 }}
PAGE["密码输入法"]["完成"] = {Unit = 0,Pixelpoint = {1061,   295, 0x2c90fd }}


PAGE["密码输入"] = {}	
PAGE["密码输入"]["密码输入"] = {Unit = 0,Pixelpoint = {779,  269, 0xffffff }}
PAGE["密码输入"]["登陆"] = {Unit = 0,Pixelpoint = {846,  215, 0x2b84d8 }}

PAGE["封号界面"] = {}		
PAGE["封号界面"]["咨询"] = {Unit = 0,Pixelpoint = { 469,   471, 0xb9a672 }}
PAGE["封号界面"]["确认"] = {Unit = 0,Pixelpoint = { 679,   465, 0x7a6438 }}
PAGE["封号界面"]["关闭"] = {Unit = 0,Pixelpoint = { 842,   171, 0xf7f0de }}

PAGE["无法链接"] = {}		
PAGE["无法链接"]["公告"] = {Unit = 0,Pixelpoint = { 469,   471, 0xb9a672 }}
PAGE["无法链接"]["确认"] = {Unit = 0,Pixelpoint = { 679,   465, 0x7a6438 }}

PAGE["黑色星期5"] = {}		
PAGE["黑色星期5"]["图标"] = {Unit = 0,Pixelpoint = { 976,   43, 0x503a11 }}
PAGE["黑色星期5"]["关闭"] = {Unit = 0,Pixelpoint = { 987,    50, 0x2b1d16 }}


PAGE["广告界面"] = {}		
PAGE["广告界面"]["不在提示"] = {Unit = 0,Pixelpoint = { 137,   595, 0x242a34 }}
PAGE["广告界面"]["关闭"] = {Unit = 0,Pixelpoint = {1001,   589, 0xcccccd }}

PAGE["签到活动"] = {}		    
PAGE["签到活动"]["图标"] = {Unit = 0,Pixelpoint = { 364,   64, 0xedcc89 }}
PAGE["签到活动"]["关闭"] = {Unit = 0,Pixelpoint = {924,   44, 0xf7f1e3 }}

PAGE["竞技场周奖励"] = {}		    
PAGE["竞技场周奖励"]["图标"] = {Unit = 0,Pixelpoint = {478,   79, 0x95836f }}
PAGE["竞技场周奖励"]["关闭"] = {Unit = 0,Pixelpoint = {832,   84, 0x4d380f }}


PAGE["开始界面"] = {}
PAGE["开始界面"]["图标"] = {Unit = 0,Pixelpoint = { 516,   533, 0xe7e8e2 }}
PAGE["开始界面"]["图标1"] = {Unit = 0,Pixelpoint = { 551,   534, 0xe5e4e0 }}
PAGE["开始界面"]["图标2"] = {Unit = 0,Pixelpoint = { 581,   535, 0xe8e7e5 }}
PAGE["开始界面"]["图标3"] = {Unit = 0,Pixelpoint = { 620,   538, 0xe6e4e8 }}
PAGE["开始界面"]["图标4"] = {Unit = 0,Pixelpoint = { 533,   546, 0x303230 }}
PAGE["开始界面"]["图标5"] = {Unit = 0,Pixelpoint = { 601,   555, 0x292c37 }}
PAGE["开始界面"]["图标6"] = {Unit = 0,Pixelpoint = { 649,   555, 0x0f1e35 }}
PAGE["开始界面"]["图标7"] = {Unit = 0,Pixelpoint = { 629,   523, 0x202c5d }}


PAGE["礼物箱子"] = {}
PAGE["礼物箱子"]["礼物箱子"] = {Unit = 0,Pixelpoint = {207,   57, 0x4f2003}}
PAGE["礼物箱子"]["收取"] = {Unit = 0,Pixelpoint = {891,  223, 0xc1995b}}

PAGE["礼物开箱子"] = {}
PAGE["礼物开箱子"]["图标"] = {Unit = 0,Pixelpoint = { 434,   354, 0xff345c }}
PAGE["礼物开箱子"]["图标1"] = {Unit = 0,Pixelpoint = { 632,   363, 0xfff2ff }}


PAGE["公会收件箱"] = {}	
PAGE["公会收件箱"]["图标"] = {Unit = 0,Pixelpoint = {382,   71, 0x512504 }}
PAGE["公会收件箱"]["收取"] = {Unit = 0,Pixelpoint = {891,  223, 0xc1995b}}
PAGE["公会收件箱"]["关闭"] = {Unit = 0,Pixelpoint = {1007,  100, 0x4c3610}}

PAGE["符文确认"] = {}	
PAGE["符文确认"]["出售"] = {Unit = 0,Pixelpoint = { 542,   489, 0xc99c58 }}
PAGE["符文确认"]["确认"] = {Unit = 0,Pixelpoint = { 693,   503, 0x897244 }}

PAGE["礼物确认"] = {}	
PAGE["礼物确认"]["确认"] = {Unit = 0,Pixelpoint = { 542,   385, 0xf8e9ad }}
PAGE["礼物确认"]["出售"] = {Unit = 0,Pixelpoint = { 611,   389, 0xc99b43 }}

PAGE["符文解除"] = {}	
PAGE["符文解除"]["是"] = {Unit = 0,Pixelpoint = {  462,  388, 0xb6a36f }}
PAGE["符文解除"]["否"] = {Unit = 0,Pixelpoint = { 674,  385, 0x412702 }}

PAGE["太古确认"] = {}	
PAGE["太古确认"]["出售"] = {Unit = 0,Pixelpoint = { 436,  433, 0xcca059 }}
PAGE["太古确认"]["确认"] = {Unit = 0,Pixelpoint = { 624,  432, 0xcda15a }}	

PAGE["切换礼物"] = {}	
PAGE["切换礼物"]["礼物"] = {Unit = 0,Pixelpoint = { 1020,   96, 0xf7efe1 }}
PAGE["切换礼物"]["公会"] = {Unit = 0,Pixelpoint = { 438,   63, 0x382a23 }}	


PAGE["关闭礼物"] = {}	
PAGE["关闭礼物"]["友情点"] = {Unit = 0,Pixelpoint = {119,  109, 0x5d4526 }}
PAGE["关闭礼物"]["刷新"] = {Unit = 0,Pixelpoint = { 867,  144, 0xcda246 }}
PAGE["关闭礼物"]["关闭"] = {Unit = 0,Pixelpoint = {1015,  100, 0x56472b }}

PAGE["关闭礼包"] = {}
PAGE["关闭礼包"]["图标1"] = {Unit = 0,Pixelpoint = {128,   34, 0x6a512f }}
PAGE["关闭礼包"]["图标2"] = {Unit = 0,Pixelpoint = {516,   31, 0x372718 }}
PAGE["关闭礼包"]["关闭礼包"] = {Unit = 0,Pixelpoint = {998,   32, 0xf6efe1}}

PAGE["五星进化礼包"] = {}	
PAGE["五星进化礼包"]["图标"] = {Unit = 0,Pixelpoint = { 461,    75, 0xf8cc62 }}
PAGE["五星进化礼包"]["关闭"] = {Unit = 0,Pixelpoint = {1005,    37, 0xf6f0e0 }}

PAGE["新手特别礼物"] = {}	
PAGE["新手特别礼物"]["图标"] = {Unit = 0,Pixelpoint = { 453,    67, 0xeab522 }}
PAGE["新手特别礼物"]["关闭"] = {Unit = 0,Pixelpoint = { 999,    66, 0xf5ecdd }}

PAGE["新闻与公告"] = {}	
PAGE["新闻与公告"]["图标"] = {Unit = 0,Pixelpoint = {1098,    36, 0xffffff }}
PAGE["新闻与公告"]["关闭"] = {Unit = 0,Pixelpoint = {1082,    49, 0x1d3842 }}


PAGE["关闭中级礼包"] = {}
PAGE["关闭中级礼包"]["图标"] = {Unit = 0,Pixelpoint = { 128,    24, 0x78643c }}
PAGE["关闭中级礼包"]["关闭礼包"] = {Unit = 0,Pixelpoint = { 991,    24, 0xf7f2df }}

PAGE["回归玩家"] = {} 
PAGE["回归玩家"]["图标"] = {Unit = 0,Pixelpoint = {704,   69, 0x841a81}}
PAGE["回归玩家"]["关闭"] = {Unit = 0,Pixelpoint = {1004,   64, 0xf6f1de }}

PAGE["购买道具"] = {} 	
PAGE["购买道具"]["图标"] = {Unit = 0,Pixelpoint = {1002,    37, 0xf8f1e1 }}
PAGE["购买道具"]["关闭"] = {Unit = 0,Pixelpoint = {1010,    44, 0xf6eee1 }}

PAGE["购买道具确认"] = {} 	
PAGE["购买道具确认"]["是"] = {Unit = 0,Pixelpoint = {463,  423, 0x70592e }}
PAGE["购买道具确认"]["否"] = {Unit = 0,Pixelpoint = {635,  427, 0xca9d41}}

PAGE["打开箱子1"] = {} 
PAGE["打开箱子1"]["图标"] = {Unit = 0,Pixelpoint = { 144,    80, 0xc7a865 }}
PAGE["打开箱子1"]["打开"] = {Unit = 0,Pixelpoint = { 635,  427, 0xca9d41 }}

PAGE["打开箱子2"] = {} 
PAGE["打开箱子2"]["图标"] = {Unit = 0,Pixelpoint = { 139,   79, 0xc7a963 }}
PAGE["打开箱子2"]["打开"] = {Unit = 0,Pixelpoint = {  84,  373, 0xcfaf29 }}

PAGE["经验增幅"] = {} 
PAGE["经验增幅"]["是"] = {Unit = 0,Pixelpoint = { 471,   381, 0x644c22 }}
PAGE["经验增幅"]["否"] = {Unit = 0,Pixelpoint = { 613,   373, 0xd5ae51 }}


PAGE["天空之城"] = {}	
PAGE["天空之城"]["头像退出"] = {Unit = 0,Pixelpoint = {122,   28, 0xc6a764 }}
PAGE["天空之城"]["战斗"] = {Unit = 0,Pixelpoint = { 636,  566, 0xaca079 }}
PAGE["天空之城"]["社交"] = {Unit = 0,Pixelpoint = {969,  559, 0x87683a}}


PAGE["切换礼物箱"] = {}
PAGE["切换礼物箱"]["礼物1"] = {Unit = 0,Pixelpoint = { 307,    74, 0x786341 }}
PAGE["切换礼物箱"]["礼物2"] = {Unit = 0,Pixelpoint = { 227,    78, 0x61523c }}
PAGE["切换礼物箱"]["关闭"] = {Unit = 0,Pixelpoint = {1148,   114, 0xeadfcc }}

PAGE["退出游戏"] = {}
PAGE["退出游戏"]["退出"] = {Unit = 0,Pixelpoint = {681,  342, 0xb6a36f }}
PAGE["退出游戏"]["咨询"] = {Unit = 0,Pixelpoint = { 639,  428, 0x29170d }}
PAGE["退出游戏"]["hive"] = {Unit = 0,Pixelpoint = {  324,  342, 0x29160f }}

PAGE["决战之岛"] = {}
PAGE["决战之岛"]["进去"] = {Unit = 0,Pixelpoint = {  543,  113, 0xffff70 }}
PAGE["决战之岛"]["打尼玛"] = {Unit = 0,Pixelpoint = { 548,  155, 0xeea821 }}


PAGE["决战之岛选择"] = {}	
PAGE["决战之岛选择"]["公会战"] = {Unit = 0,Pixelpoint = { 376,   357, 0xecbc5a }}
PAGE["决战之岛选择"]["占领站"] = {Unit = 0,Pixelpoint = { 738,   347, 0xdc4db2 }}


PAGE["返回"] = {}
PAGE["返回"]["返回"] = {Unit = 0,Pixelpoint = {1074,   575, 0xdfbf72 }}
PAGE["返回"]["图标"] = {Unit = 0,Pixelpoint = {1082,   615, 0xd9b96c }}

PAGE["夏依德遗址"] = {}
PAGE["夏依德遗址"]["夏"] = {Unit = 0,Pixelpoint = { 938,   351, 0x432904 }}
PAGE["夏依德遗址"]["依"] = {Unit = 0,Pixelpoint = { 975,   345, 0xbdb394 }}
PAGE["夏依德遗址"]["德"] = {Unit = 0,Pixelpoint = { 994,   322, 0xceb45e }}

PAGE["夏依德遗址选关"] = {}	
PAGE["夏依德遗址选关"]["图标"] = {Unit = 0,Pixelpoint = { 813,   120, 0xebc886 }}
PAGE["夏依德遗址选关"]["关闭"] = {Unit = 0,Pixelpoint = {1097,    50, 0xf8f0e2 }}


------------------------------------------------------------------------------------------------------------ 战斗部分
PAGE["战斗信息"] = {}	
PAGE["战斗信息"]["战斗信息"] = {Unit = 0,Pixelpoint = { 580,   103, 0xaf9f8c }}
PAGE["战斗信息"]["关闭"] = {Unit = 0,Pixelpoint = {1000,   108, 0xf9f4e1 }}
PAGE["战斗信息"]["攻击"] = {Unit = 0,Pixelpoint = { 568,   573, 0x422803 }}

PAGE["公会战"] = {}	
PAGE["公会战"]["图标"] = {Unit = 0,Pixelpoint = { 196,    25, 0x8f6139 }}
PAGE["公会战"]["关闭"] = {Unit = 0,Pixelpoint = {1104,    25, 0xe5d5b4 }}
PAGE["公会战"]["开始战斗"] = {Unit = 0,Pixelpoint = { 906,   439, 0xcea54a }}
PAGE["公会战"]["结束战斗"] = {Unit = 0,Pixelpoint = { 947,   570, 0xcabd8b }}

PAGE["开始战斗"] = {}	
PAGE["开始战斗"]["图标"] = {Unit = 0,Pixelpoint = { 208,   588, 0xffffff }}
PAGE["开始战斗"]["开始"] = {Unit = 0,Pixelpoint = { 208,   601, 0xffffff }}

PAGE["胜利"] = {}	
PAGE["胜利"]["胜利"] = {Unit = 0,Pixelpoint = { 553,   111, 0xffdb43 }}
PAGE["胜利"]["对战"] = {Unit = 0,Pixelpoint = { 595,   266, 0xead98b }}


--等待页面并点击，page:需要等待出现的页面，sleeptime:等待间隔，timeout:等待超时时间,fuzzy:找色相似度
function WaitingAndClick(waitpage,clickicon,unit,timeout,sleeptime,fuzzy)
	sleeptime = sleeptime or 1000 --默认重复判断等待时间为1000毫秒
	timeout = timeout or 3000 --默认超时时间3000毫秒
	fuzzy = fuzzy or 90 --默认相似度90%
	unit = unit or 0 --内面内部部件，默认标签为0

	--单点模糊比色
	local function IsColor(pixelpoint,fuzzy)
		local fl,abs = math.floor,math.abs
		fuzzy = fl(0xff*(100-fuzzy)*0.01)
		local r,g,b = fl(pixelpoint[3]/0x10000),fl(pixelpoint[3]%0x10000/0x100),fl(pixelpoint[3]%0x100)
		local rr,gg,bb = getColorRGB(pixelpoint[1],pixelpoint[2])
		if abs(r-rr)<fuzzy and abs(g-gg)<fuzzy and abs(b-bb)<fuzzy then
			return true
		end
	end

	if waitpage[clickicon].Unit ~= unit and waitpage[clickicon].Unit ~=0 then
		nLog("标签错误，请仔细核对")
		return
	end

	local curtime = 0
	local mismatching = 0
	while true do
		for k,v in pairs(waitpage) do
			if v.Pixelpoint and (v.Unit == unit or v.Unit == 0) and  not IsColor(v.Pixelpoint,fuzzy) then
				nLog("图标：<"..k..">不匹配")
				mismatching = 1
				break
			end
		end 
		if mismatching == 0 then break end
		mismatching = 0
		if curtime >= timeout then
			nLog("超时未找到页面")
			return 
		end
		mSleep(sleeptime)
		curtime = curtime + sleeptime
	end

	touchDown(0,waitpage[clickicon].Pixelpoint[1],waitpage[clickicon].Pixelpoint[2])
	mSleep(100)
	touchUp(0,waitpage[clickicon].Pixelpoint[1],waitpage[clickicon].Pixelpoint[2])
	return true

end


function pdd( xzb, yzb,yanse ); -----判断点的颜色 正确true 错误 false
	xzbs, yzbs = findColorInRegionFuzzy(yanse, 98, xzb, yzb, xzb, yzb); 
	if xzbs ~= -1 and yzbs ~= -1 then
		return true;
	else
		return false;
	end
end

function dianji(xdian, ydian);
	touchDown(1, xdian, ydian) 
	mSleep(33)
	touchUp(1, xdian, ydian)
	mSleep(400)
end

function dianliang();
	if pdd(546, 399, 0x007aff) and pdd(582, 394, 0x007aff) then --出现电量提示
		dianji(563, 398);
	end
end

function gb()
	if pdd( 559,  576, 0x352a14) then
		dianji(998,  108);
		mSleep(3000);
	end	-- body
end


function gg()
	--关闭所有广告
	xa, ya = findColorInRegionFuzzy(0xf8f0e0, 98, 816, 14, 1024, 158); 
	if xa ~= -1 and ya ~= -1 then
		dianji(xa, ya);
		mSleep(2000);
	end	
end



init(2)

tab=readFile(userPath().."/res/账号密码.txt") 
if tab then 
	for var= 1, #tab do
		toast(tab[1],1)
		mSleep(1000)
		data = strSplit(string.gsub(tab[1],"%s+",""),"----")
		
		insertData = tab[1]
		table.remove(tab,1)
		table.insert(tab,insertData)

		writeFile(userPath().."/res/账号密码.txt",tab,"w",1) 
		mSleep(1000)
		
		for x=1,10,1 do  
			if getColor(508,  548 )== 0x999ba8 and getColor(508,  548 )== 0x999ba8 and getColor(579,  546 )== 0x999cb1 then
				break
			end
			if getColor(840,  255 )== 0x2b84d8 and getColor(587,  117)==  0xeeeeee and getColor(413,  444)== 0x2b84d8 then
				break
			end
			if getColor(141,  591)== 0x242a34 and getColor(1000,  585)== 0x020202  then   --跳过广告宣传其他游戏的那种
				break 
			end
			if getColor(1098,  574)== 0x644a4f and getColor(1082,  556)== 0x391828  then  --跳过登陆游戏
				break 
			end
			if getColor(215,  302 )== 0xfadac3 and getColor(249,  282)== 0x053c5a  then  --跳过回归礼物
				break
			end
			if getColor(141,  588)== 0x38404d and getColor(1003,  595)== 0xcdcdcd  then     --跳过广告宣传其他游戏的那种
				break
			end
			if getColor(990,   40)== 0xfcefe5 and getColor( 998,   33)== 0xfbf6e9  then     --天空之城有遮挡
				break
			end
			if getColor( 20,   53)== 0xb89c52  then     --天空之城无遮挡
				break
			end
			if getColor( 1062,  573)== 0xdbbc6c  then     --战斗界面
				break
			end
			if getColor( 1098,   36)== 0xffffff  then    --新闻与公告
				break
			end

			toast("开启游戏和辅助",1)
			isfront = isFrontApp("com.com2us.smon.normal.freefull.apple.kr.ios.universal"); --更新前台状态
			if isfront == 0 then -- 0 == 不在前台运行
				runApp("com.com2us.smon.normal.freefull.apple.kr.ios.universal"); --启动应用
				mSleep(100);	
			end
			WaitingAndClick(PAGE["iosgod"],"thankyou",0,10000)
			WaitingAndClick(PAGE["iosgod"],"thankyou",0,5000)
			mSleep(3000)
			WaitingAndClick(PAGE["使用"],"继续",0,3000)
			mSleep(3000)
			WaitingAndClick(PAGE["小米"],"打勾",0,3000)
			mSleep(1000)
			--WaitingAndClick(PAGE["返回游戏"],"返回游戏",0,1000)
			mSleep(1000)
			WaitingAndClick(PAGE["点击画面"],"魔灵",0,1000)
			WaitingAndClick(PAGE["无法链接"],"确认",0,1000)
			gg()
		end


		for u =1,20,1 do
			if getColor(990,   40)== 0xfcefe5 and getColor( 998,   33)== 0xfbf6e9  then     --天空之城有遮挡
				break
			end
			if getColor( 20,   53)== 0xb89c52  then     --天空之城无遮挡
				break
			end
			if getColor( 1062,  573)== 0xdbbc6c  then     --战斗界面
				break
			end
			if getColor( 1098,   36)== 0xffffff  then    --新闻与公告
				break
			end

			gg()
			toast("登陆游戏",1)
			WaitingAndClick(PAGE["返回游戏"],"返回游戏",0,3000)
			mSleep(3000)
			WaitingAndClick(PAGE["点击画面"],"魔灵",0,1000)
			WaitingAndClick(PAGE["登陆界面"],"账号输入",0,30000)
			mSleep(1000)
			for i=1,20,1 do
				WaitingAndClick(PAGE["输入法"],"删除",0,60)	
			end	
			mSleep(2000)    
			inputText (data[1])--账号
			mSleep(2000)
			WaitingAndClick(PAGE["输入法"],"完成",0,1000)
			mSleep(2000)
			WaitingAndClick(PAGE["登陆界面"],"密码输入",0,3000)
			--WaitingAndClick(PAGE["密码输入"],"密码输入",0,3000)
			mSleep(2000)
			inputText (data[2])--密码
			mSleep(2000)
			WaitingAndClick(PAGE["密码输入法"],"完成",0,3000)
			mSleep(2000)
			WaitingAndClick(PAGE["登陆界面"],"登陆",0,3000)
			WaitingAndClick(PAGE["密码输入"],"登陆",0,3000)
			WaitingAndClick(PAGE["小米"],"打勾",0,3000)
			WaitingAndClick(PAGE["无法链接"],"确认",0,1000)
			WaitingAndClick(PAGE["开始界面"],"图标",0,10000)
			mSleep(5000)
			gg()
		end


		for j=1,30,1 do   --关闭广告
			toast("关闭广告",1)
			WaitingAndClick(PAGE["无法链接"],"确认",0,600)
			WaitingAndClick(PAGE["开始界面"],"图标",0,500)
			WaitingAndClick(PAGE["广告界面"],"不在提示",0,500)
			WaitingAndClick(PAGE["回归玩家"],"关闭",0,500)
			WaitingAndClick(PAGE["签到活动"],"关闭",0,500)
			WaitingAndClick(PAGE["黑色星期5"],"关闭",0,500)
			WaitingAndClick(PAGE["五星进化礼包"],"关闭",0,500)
			WaitingAndClick(PAGE["关闭礼包"],"关闭礼包",0,500)
			WaitingAndClick(PAGE["关闭中级礼包"],"关闭礼包",0,500)
			WaitingAndClick(PAGE["关闭礼物"],"关闭",0,500)
			WaitingAndClick(PAGE["新手特别礼物"],"关闭",0,500)
			WaitingAndClick(PAGE["竞技场周奖励"],"关闭",0,500)
			WaitingAndClick(PAGE["新闻与公告"],"关闭",0,500)
			gg()
			mSleep(1000)
			if getColor(986,  148)== 0xec3163 then
				break
			end
			if getColor( 1062,  573)== 0xdbbc6c  then     --战斗界面
				break
			end
		end

		WaitingAndClick(PAGE["打开箱子1"],"打开",0,3000)
		WaitingAndClick(PAGE["打开箱子2"],"打开",0,3000)


		for l=1,30,1 do   --领取礼物奖励
			toast("领取礼物奖励",10)
			WaitingAndClick(PAGE["打开箱子1"],"打开",0,1000)
			WaitingAndClick(PAGE["打开箱子2"],"打开",0,1000)
			WaitingAndClick(PAGE["礼物箱子"],"收取",0,1000)
			WaitingAndClick(PAGE["礼物开箱子"],"图标",0,1000)
			WaitingAndClick(PAGE["符文确认"],"确认",0,1000)
			WaitingAndClick(PAGE["礼物确认"],"确认",0,1000)
			WaitingAndClick(PAGE["太古确认"],"确认",0,1000)
			WaitingAndClick(PAGE["经验增幅"],"是",0,1000)
			mSleep(5000)
			if getColor(891,  223)== 0x2f2212 then
				break
			end
			if getColor( 1062,  573)== 0xdbbc6c  then     --战斗界面
				break
			end
		end
		mSleep(2000)


		for g=1,30,1 do   --领取公会奖励
			toast("领取公会礼物奖励",10)
			WaitingAndClick(PAGE["切换礼物"],"公会",0,3000) 
			WaitingAndClick(PAGE["公会收件箱"],"收取",0,1000)
			WaitingAndClick(PAGE["礼物开箱子"],"图标",0,1000)
			WaitingAndClick(PAGE["符文确认"],"确认",0,1000)
			WaitingAndClick(PAGE["礼物确认"],"确认",0,1000)
			mSleep(5000)
			if getColor(891,  223)== 0x2f2212 then
				break
			end
			if getColor( 1062,  573)== 0xdbbc6c  then     --战斗界面
				break
			end
		end
		mSleep(2000)
		WaitingAndClick(PAGE["关闭礼物"],"关闭",0,1000)
		WaitingAndClick(PAGE["返回"],"返回",0,1000)
		mSleep(2000)
		--WaitingAndClick(PAGE["天空之城"],"头像退出",0,3000)
		--WaitingAndClick(PAGE["退出游戏"],"退出",0,3000)


		for gx= 1,30,1 do   ---进入公会战
			WaitingAndClick(PAGE["返回"],"返回",0,1000)
			WaitingAndClick(PAGE["天空之城"],"战斗",0,1000)
			WaitingAndClick(PAGE["夏依德遗址"],"夏",0,1001)
			WaitingAndClick(PAGE["夏依德遗址"],"夏",0,1001)
			WaitingAndClick(PAGE["夏依德遗址选关"],"关闭",0,1001)
			WaitingAndClick(PAGE["决战之岛"],"进去",0,3001)
			WaitingAndClick(PAGE["决战之岛选择"],"公会战",0,3001)
			if getColor(300, 32 )== 0xff7b00 then
				break
			end
		end

		for gh=1,30,1 do    ----公会战

			if pdd(282,  263, 0x3b120f) then	--第一个
				dianji(282,  263);
				mSleep(3000);
			end	
			gb()
			if pdd(263,  539, 0x8c1f0b) then	--第二个
				dianji(263,  539);
				mSleep(3000);
			end	
			gb()
			if pdd(520,  471, 0x81230d) then	--第三个
				dianji(520,  471);
				mSleep(3000);
			end	
			gb()
			if pdd(584,  282, 0x7e280b) then	--第四个
				dianji(584,  282);
				mSleep(3000);
			end	
			gb()
			if pdd(807,  365, 0x852109) then	--第五个
				dianji(807,  365);
				mSleep(3000);
			end	
			gb()
			if pdd(958,  494, 0x7e280c) then	--第六个
				dianji(958,  494);
				mSleep(3000);
			end	
			gb()


			WaitingAndClick(PAGE["战斗信息"],"攻击",0,1001)
			WaitingAndClick(PAGE["公会战"],"开始战斗",0,1001)
			WaitingAndClick(PAGE["开始战斗"],"开始",0,1001) 
			WaitingAndClick(PAGE["胜利"],"对战",0,1001) 
			if pdd(683,  159, 0xaba586) then	--每日奖励
				dianji(683,  159);
				mSleep(1000);
			end	 

			if pdd(534,   72, 0x806041) then	--每日奖励
				dianji(1077,  583);
				mSleep(1000);

				if pdd(1006,   39, 0xf9f2e2) then	--每日奖励
					dianji(1006,   39);
					mSleep(1000);

				end
				WaitingAndClick(PAGE["购买道具"],"关闭",0,1000)
				WaitingAndClick(PAGE["购买道具确认"],"是",0,1000)
				WaitingAndClick(PAGE["返回"],"返回",0,1000)
				mSleep(2000)
				WaitingAndClick(PAGE["天空之城"],"头像退出",0,1000)
				WaitingAndClick(PAGE["退出游戏"],"退出",0,1000)
			end
		end

		dialog("脚本已经停止！",5); 
		mSleep(1000); 
		vibrator();
		mSleep(1000);
		lua_exit(); --退出脚本]]--
	end
else
	dialog("文件不存在")
end